package Test2;
/**
 *
 * @author 29284
 * @since 2024/11/29 21:08
 */
public class PhoneTest {
    public static void main(String[] args) {
        Phone[] phone = new Phone[3];
        int sum = 0;
        Phone P1=new Phone("华为",8999,"白色");
        Phone p2=new Phone("小米",4999,"粉色");
        Phone p3=new Phone("苹果",19999,"蓝色");
        phone[0]=P1;
        phone[1]=p2;
        phone[2]=p3;
        for (int i = 0; i < phone.length; i++) {
            sum+=phone[i].getPrice();
        }
        int avgPrice = sum/phone.length;
        System.out.println("三部手机的平均价格是"+avgPrice+"元");
    }
}
